with open('test/pi_digits.txt') as file_object:
    contents = file_object.read()
print(contents)

print()
#逐行读取
filename = 'pi_digits.txt'
with open(filename) as file_obj:
    for line in file_obj:
        print(line.rstrip())

#创建一个包含文件各行内容的列表
filename = 'pi_digits.txt'
with open(filename) as file_obj:
    lines = file_obj.readlines()
pi_string =''
for line in lines:
    pi_string += line.rstrip()
print(pi_string)